#!/bin/sh

NAME=$1
TOP=$(dirname $0)

PREFIX=
if [ $NAME == '-f' ]; then
    PREFIX=Force
    NAME=$2
fi

if [ "$NAME" == "" ]; then
  echo "Syntax: $0 <Module Name>"
  exit 1
fi

HDR=${NAME}Module.h
SRC=${NAME}Module.cpp

if [ -e $HDR -o -e $SRC ]; then
  echo Module $NAME exists
  exit 1
fi

SED="s/Template/$NAME/g"
SED+=";s/TEMPLATE/$(echo -n ${NAME}|sed 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/')/g"

sed $SED <$TOP/${PREFIX}TemplateModule.h>$HDR
sed $SED <$TOP/${PREFIX}TemplateModule.cpp>$SRC
